/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class OperationRequest
    {
    
        private  HTTPHeaders HTTPHeadersField;
        private String requestIdField;

        private  Arguments argumentsField;
        private Single? requestProcessingTimeField;


        /// <summary>
        /// Gets and sets the HTTPHeaders property.
        /// </summary>
        [XmlElementAttribute(ElementName = "HTTPHeaders")]
        public HTTPHeaders HTTPHeaders
        {
            get { return this.HTTPHeadersField ; }
            set { this.HTTPHeadersField = value; }
        }



        /// <summary>
        /// Sets the HTTPHeaders property
        /// </summary>
        /// <param name="HTTPHeaders">HTTPHeaders property</param>
        /// <returns>this instance</returns>
        public OperationRequest WithHTTPHeaders(HTTPHeaders HTTPHeaders)
        {
            this.HTTPHeadersField = HTTPHeaders;
            return this;
        }



        /// <summary>
        /// Checks if HTTPHeaders property is set
        /// </summary>
        /// <returns>true if HTTPHeaders property is set</returns>
        public Boolean IsSetHTTPHeaders()
        {
            return this.HTTPHeadersField != null;
        }




        /// <summary>
        /// Gets and sets the RequestId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "RequestId")]
        public String RequestId
        {
            get { return this.requestIdField ; }
            set { this.requestIdField= value; }
        }



        /// <summary>
        /// Sets the RequestId property
        /// </summary>
        /// <param name="requestId">RequestId property</param>
        /// <returns>this instance</returns>
        public OperationRequest WithRequestId(String requestId)
        {
            this.requestIdField = requestId;
            return this;
        }



        /// <summary>
        /// Checks if RequestId property is set
        /// </summary>
        /// <returns>true if RequestId property is set</returns>
        public Boolean IsSetRequestId()
        {
            return  this.requestIdField != null;

        }


        /// <summary>
        /// Gets and sets the Arguments property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Arguments")]
        public Arguments Arguments
        {
            get { return this.argumentsField ; }
            set { this.argumentsField = value; }
        }



        /// <summary>
        /// Sets the Arguments property
        /// </summary>
        /// <param name="arguments">Arguments property</param>
        /// <returns>this instance</returns>
        public OperationRequest WithArguments(Arguments arguments)
        {
            this.argumentsField = arguments;
            return this;
        }



        /// <summary>
        /// Checks if Arguments property is set
        /// </summary>
        /// <returns>true if Arguments property is set</returns>
        public Boolean IsSetArguments()
        {
            return this.argumentsField != null;
        }




        /// <summary>
        /// Gets and sets the RequestProcessingTime property.
        /// </summary>
        [XmlElementAttribute(ElementName = "RequestProcessingTime")]
        public Single RequestProcessingTime
        {
            get { return this.requestProcessingTimeField.GetValueOrDefault() ; }
            set { this.requestProcessingTimeField= value; }
        }



        /// <summary>
        /// Sets the RequestProcessingTime property
        /// </summary>
        /// <param name="requestProcessingTime">RequestProcessingTime property</param>
        /// <returns>this instance</returns>
        public OperationRequest WithRequestProcessingTime(Single requestProcessingTime)
        {
            this.requestProcessingTimeField = requestProcessingTime;
            return this;
        }



        /// <summary>
        /// Checks if RequestProcessingTime property is set
        /// </summary>
        /// <returns>true if RequestProcessingTime property is set</returns>
        public Boolean IsSetRequestProcessingTime()
        {
            return  this.requestProcessingTimeField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetHTTPHeaders()) {
                HTTPHeaders  HTTPHeaders = this.HTTPHeaders;
                xml.Append("<HTTPHeaders>");
                xml.Append(HTTPHeaders.ToXMLFragment());
                xml.Append("</HTTPHeaders>");
            } 
            if (IsSetRequestId()) {
                xml.Append("<RequestId>");
                xml.Append(EscapeXML(this.RequestId));
                xml.Append("</RequestId>");
            }
            if (IsSetArguments()) {
                Arguments  arguments = this.Arguments;
                xml.Append("<Arguments>");
                xml.Append(arguments.ToXMLFragment());
                xml.Append("</Arguments>");
            } 
            if (IsSetRequestProcessingTime()) {
                xml.Append("<RequestProcessingTime>");
                xml.Append(this.RequestProcessingTime);
                xml.Append("</RequestProcessingTime>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}